
class ImageApiMixin(object):
    def __init__(self):
        self.log = NotImplementedError()
        self.username = NotImplementedError()

    def api_call(self, api, data, async=False, period=60.0):
        NotImplementedError()

    def get_api_result(self, res, api_name=False):
        NotImplementedError()

    def query_image(self, data=None, async=False):
        """
        QueryImage
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'conditions': [{'name': 'uuid',
                         'op': '=',
                         'value': 'b30fff0ee72945f7a3236a1fbd219bea'}],
         'session': {'uuid': 'eb1327a919414b5fa4e0fad26c48a3c1'}}
        """
        if data is None:
            data = {}
        if data.get('conditions') is None:
            data['conditions'] = []
        rsp = self.api_call("org.zstack.header.image.APIQueryImageMsg", data, async=async)
        return self.get_api_result(rsp)

    def update_image(self, data, async=False):
        """
        UpdateImage
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'name': 'test001',
         'session': {'callid': 'api-zIetMdnl',
                     'uuid': '1a9ce40db2454ac389e85f6ffb4ace20'},
         'uuid': '9ba1839f6af94ebeab22ab517912feb0'}
        """
        rsp = self.api_call("org.zstack.header.image.APIUpdateImageMsg", data, async=async)
        return self.get_api_result(rsp)

    def query_user_tag(self, data=None, async=False):
        """
        QueryUserTag
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'conditions': [{'name': 'resourceUuid',
                         'op': '=',
                         'value': 'b30fff0ee72945f7a3236a1fbd219bea'}],
         'session': {'uuid': '0290b94e8e814751a2427eeaef6b83ca'}}
        """
        if data is None:
            data = {}
        if data.get('conditions') is None:
            data['conditions'] = []
        rsp = self.api_call("org.zstack.header.tag.APIQueryUserTagMsg", data, async=async)
        return self.get_api_result(rsp)

    def create_user_tag(self, data, async=False):
        """
        CreateUserTag
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'resourceType': 'ImageVO',
         'resourceUuid': '6fb44821c3d342088fd35681a0734eb3',
         'session': {'uuid': '6a76beae90664c2aafcd4914f79ba44e'},
         'tag': 'golden-image'}
        """
        rsp = self.api_call("org.zstack.header.tag.APICreateUserTagMsg", data, async=async)
        return self.get_api_result(rsp)

    def delete_tag(self, data, async=False):
        """
        DeleteTag
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'session': {'uuid': '6a76beae90664c2aafcd4914f79ba44e'},
         'uuid': '22b231b5d8e349caa3dc2c67318d570d'}
        """
        rsp = self.api_call("org.zstack.header.tag.APIDeleteTagMsg", data, async=async)
        return self.get_api_result(rsp)

    def delete_image(self, data, async=False):
        """
        DeleteImage
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'session': {'callid': 'api-Ite71fbt',
                     'uuid': '1a9ce40db2454ac389e85f6ffb4ace20'},
         'uuid': '9ba1839f6af94ebeab22ab517912feb0'}
        """
        rsp = self.api_call("org.zstack.header.image.APIDeleteImageMsg", data, async=async)
        return self.get_api_result(rsp)

    def add_image(self, data, async=False):
        """
        AddImage
        :param async: Can be used to asynchronously execute code.
        :param data:
        {'backupStorageUuids': ['74885916b5924c258bccf37c5ef800d1'],
         'description': '',
         'format': 'qcow2',
         'mediaType': 'RootVolumeTemplate',
         'name': 'testtest',
         'platform': 'Linux',
         'session': {'callid': 'api-P18EavnT',
                     'uuid': '1a9ce40db2454ac389e85f6ffb4ace20'},
         'system': False,
         'systemTags': [],
         'url': 'http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-server-i386.iso'}
        """
        rsp = self.api_call("org.zstack.header.image.APIAddImageMsg", data, async=async)
        return self.get_api_result(rsp)
